﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace ECSS.Winform
{
    public partial class ResOrderEntryAccount : Form
    {
        BOSSInterfaceInvoke wcf;

        public ResOrderEntryAccount()
        {
            InitializeComponent();
            wcf = new BOSSInterfaceInvoke();
        }

        private void btnRequest_Click_1(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(txtOrderIDs.Text.Trim())
                && txtOrderIDs.Lines.Count() > 0)
            {
                for (int i = 0; i < txtOrderIDs.Lines.Count(); i++)
                {
                    string orderids = txtOrderIDs.Lines[i];
                    if (string.IsNullOrEmpty(orderids)) continue;

                    try
                    {
                        string orderid = orderids.Split("\t".ToCharArray())[0];
                        string mobile = orderids.Split("\t".ToCharArray())[1];

                        bool flag = false;
                        string msg;

                        wcf.ReserveOrderEntryAccount(mobile, orderid, 0, false, "Cash", "", out flag, out flag, out msg);

                    }
                    catch (Exception ex)
                    {
                        sb.Append(ex.Message + "\r\n");
                    }

                    Thread.Sleep(300);
                }
            }
            if (!string.IsNullOrEmpty(sb.ToString()))
                MessageBox.Show(sb.ToString());
        }

        private void btnClear_Click_1(object sender, EventArgs e)
        {
            try
            {
                string log = txtLog.Text.Trim();
                if (!string.IsNullOrEmpty(txtOrderIDs.Text.Trim())
                && txtOrderIDs.Lines.Count() > 0)
                {
                    for (int i = 0; i < txtOrderIDs.Lines.Count(); i++)
                    {
                        string orderid = txtOrderIDs.Lines[i];
                        if (string.IsNullOrEmpty(orderid)) continue;

                        if (log.Contains(orderid))
                        {
                            txtOrderIDs.Text = txtOrderIDs.Text.Replace(orderid, "");
                        }
                    }
                }
                txtLog.Text = "";
            }
            catch (Exception ex)
            {
            }
        }

    }
}
